<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
    <title>试卷编辑</title>
    <c:import url="/layout/_imports.jsp"></c:import>
    <style>
        .manage_items a{
            text-decoration: none;
            color: #fff;
        }
    </style>
</head>
<body>
<c:import url="/layout/_nav.jsp"></c:import>
<div class="container">
    <h2>试卷编辑</h2>
    <h2>当前试卷：${paper.title}</h2>
    <form action="/paper/update" method="post">
        <input type="hidden" name="id" value="${paper.id}">
        <input type="hidden" name="page" value="${page}">
        <input type="hidden" name="size" value="${size}">
        <div class="form-group row">
            <label class="col-sm-2" for="title">试卷名</label>
            <div class="col-sm-10">
                <input class="form-control" id="title" type="text" name="title"  value="${paper.title}"/>
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2" for="begin">答题时间</label>
            <div class="col-sm-10">
                <input type="hidden" id="change_time" value="<fmt:formatDate value="${paper.begin}" pattern="yyyy-MM-dd HH:mm:ss"/>">
                <input class="form-control" id="begin" type="datetime-local" name="begin" value="" />
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2" for="limitation">时限</label>
            <div class="col-sm-10">
                <input class="form-control" id="limitation" type="number" name="limitation" value="${paper.limitation}" />
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2" for="amount">题目数</label>
            <div class="col-sm-10">
                <input class="form-control" id="amount" type="number" disabled value="${itemsCount.get(paper.id) != null?itemsCount.get(paper.id):"0"}" />
            </div>
        </div>
        <button type="submit" class="btn btn-primary">保存</button>
        <button type="button" class="btn btn-primary manage_items">
            <a href="/paper/itemsManage?id=${paper.id}">管理题目</a>
        </button>
        <a href="/paper/manage?page=${page}&size=${size}" class="btn btn-secondary">返回列表</a>
    </form>
</div>

<script>
    $(document).ready(function () {
        var begin_time = $("#change_time").val();
        begin_time = begin_time.replace(" ", "T")
        $("#begin").val(begin_time);
    })
</script>
</body>
</html>
